package com.itboye.shopcar_adapter;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.itboye.mengwu.R;
import com.itboye.mengwu.data.model.GridViewBean;

public class ShopXiangQingGridViewAdapter extends BaseAdapter {

	ArrayList<GridViewBean> list;
	Context context;

	public ShopXiangQingGridViewAdapter(ArrayList<GridViewBean> list,
			Context context) {
		this.list = list;
		this.context = context;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		Houder houder;
		if (convertView == null) {
			houder = new Houder();
			convertView = LayoutInflater.from(context).inflate(
					R.layout.item_xiangqing_gridview, null);
			houder.img = (ImageView) convertView
					.findViewById(R.id.imgXiangQing);
			houder.tilte = (TextView) convertView
					.findViewById(R.id.tv_xiangqing);
			convertView.setTag(houder);
		} else {
			houder = (Houder) convertView.getTag();
		}
		houder.tilte.setText(list.get(position).getCountext());
		houder.img.setImageResource(list.get(position).getUrl());
		return convertView;
	}

	class Houder {
		ImageView img;
		TextView tilte;
	}

}
